<?php
include('../config.php');
header("Access-Control-Allow-Origin:*");


$goodid = $_POST['goodid'];
$sql = "select * from goods where goodid=$goodid";

// $res时一个资源类型
$res = mysql_query($sql);
if ($res) {
  $list = array();
// 通过循环去资源里抓取数据，每取一行，都是一个$row，取完了循环也就结束了
  while ($row = mysql_fetch_assoc($res)) {
    array_push($list, $row);
  }
// 按照接口文档返回对应的数据格式
  echo json_encode(array(
    "code" => 200,
    "body" => array(
      "list" => $list,
      "msg" => '查询成功'
    )
  ));
} else {
  echo json_encode(array(
    "code" => 201,
    "body" => array(
      "msg" => '网络错误，查询失败，请重试',
      "res"=>$res
    )
  ));
}

// $count=mysql_num_rows($res)
?>